From 812519079d605c57f770804733ca17c6476a48f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 7 Sep 2017 01:01:19 +0200 Subject: [PATCH] extensions: fix type error in float 2 half --- extensions/float-half.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/extensions/float-half.c b/extensions/float-half.c index b471a02..3adc10c 100644 --- a/extensions/float-half.c +++ b/extensions/float-half.c @@ -210,16 +210,19 @@ static inline unsigned short float_to_half_float(float f) union { float f; uint32_t u; - } u = {f}; - unsigned temp = u.u; - unsigned signexp = (temp >> 23) & 0x1ff; + } u; + unsigned int temp; + unsigned int signexp; + u.f = f; + temp = u.u; + signexp = (temp >> 23) & 0x1ff; return half_float_base_table[signexp] + ((temp & 0x007fffff) >> half_float_shift_table[signexp]); } static void singles2halfp(void *target, const void *source, long numel) { const float *src = source; - uint8_t *dst = target; + uint16_t *dst = target; int i; for (i = 0; i < numel; i++) dst[i] = float_to_half_float (src[i]); -- 2.30.2